package com.dd.cloud.user.entity.product;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import com.zk.pay.model.params.PayParamReq;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * <p>
 * 
 * </p>
 *
 * @author czg
 * @since 2022-09-23
 */
@Data
@EqualsAndHashCode
@Accessors(chain = true)
@Table(comment = "支付参数表")
public class PayParam implements Serializable {

    private static final long serialVersionUID=1L;

    @TableId(value = "id", type = IdType.AUTO)
    @Column(isKey = true,isAutoIncrement = true)
    private Integer id;

    /**
     * 支付类型
     */
    @Column(comment = "支付类型 wx,zfb")
    private String payType;

    /**
     * 对应的id
     */
    @Column(type = MySqlTypeConstant.TINYINT, comment = "对应的id 机构或药房")
    private Integer partyId;

    /**
     * 收款方的类型
     */
    @Column(type = MySqlTypeConstant.TINYINT, comment = "对应的id 1机构 2药房")
    private Integer partyType;

    /**
     * 收款方的类型
     */
    @Column(type = MySqlTypeConstant.TINYINT, comment = "状态 1正常 -1删除")
    private Integer status;

    /**
     * 应用id
     */
    @Column(length = 20, comment = "应用id")
    private String appId;

    /**
     * 私钥
     */
    @Column(length = 200, comment = "私钥")
    private String privateKey;

    /**
     * 公钥
     */
    @Column(length = 200, comment = "公钥")
    private String publicKey;

    /**
     * 服务器异步通知路径
     */
    @Column(length = 100, comment = "服务器异步通知路径")
    private String notifyUrl;

    /**
     * 页面通知路径
     */
    @Column(length = 100, comment = "页面通知路径")
    private String returnUrl;

    /**
     * 退款结果回调
     */
    @Column(length = 100, comment = "退款结果回调")
    private String refundNotify;
    /**
     * 商户id
     */
    @Column(length = 50, comment = "商户id")
    private String mchId;

    /**
     * 支付key
     */
    @Column(length = 100, comment = "支付key")
    private String mchKey;

    /**
     * 证书名
     */
    @Column(length = 100, comment = "证书名")
    private String certName;

    /**
     * 证书序列号值
     */
    @Column(length = 64, comment = "证书序列号值")
    private String certNo;

    /**
     * 证书序列号值
     */
    @Column(length = 10, comment = "支付api版本")
    private String version;

    /**
     * 证书序列号值
     */
    @Column(length = 20, comment = "商户主体")
    private String body;

    /**
     * 证书序列号值
     */
    @Column(length = 20, comment = "支付主题")
    private String subject;

    /**
     * 创建日期
     */
    @Column(comment = "创建日期")
    private LocalDateTime createDate;

    /**
     * 支付参数
     * @return
     */
    public PayParamReq payParam(){
        PayParamReq payParamReq = new PayParamReq();
        payParamReq.setAppId(getAppId());
        payParamReq.setCertName(getCertName());
        payParamReq.setMchId(getMchId());
        payParamReq.setMchKey(getMchKey());
        payParamReq.setNotifyUrl(getNotifyUrl() + getAppId() + "_" + getId());
        payParamReq.setRefundNotify(getRefundNotify());
        payParamReq.setPayType(getPayType());
        payParamReq.setVersion(getVersion());
        payParamReq.setPrivateKey(getPrivateKey());
        payParamReq.setCertNo(getCertNo());
        return payParamReq;
    }
}
